﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Order.Interstructrue.Base
{
    public interface IBaseRepository<T> where T : class
    {
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int Create(T entity);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int Update(T entity);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int Delete(T entity);
        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        T GetModel(int Id);
        T GetlongModel(long Id);
        /// <summary>
        /// 异步查询单个实体
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        Task<T> GetModelAsync(int Id);
        /// <summary>
        /// 批量创建
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        int CreateRange(IEnumerable<T> entities);
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        int UpdateRange(IEnumerable<T> entities);
    }
}
